#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

void wiggleSort(vector<int>& nums) {
    int n = nums.size();
    auto arr = nums;
    sort(arr.begin(), arr.end());
    int x = (n + 1) / 2;
    for (int i = 0, j = x - 1, k = n - 1; i < n; i += 2, j--, k--)
    {
        nums[i] = arr[j];
        if (i + 1 < n)
            nums[i + 1] = arr[k];
    }
}